package com.tn.controller.task;


import com.github.pagehelper.PageInfo;
import com.tn.controller.alarm.common.model.CommonVO;
import com.tn.dao.key.ShortcutKey;
import com.tn.entity.TaskInfoLocal;
import com.tn.service.task.TaskInfoLocalService;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author YuzSuzuki
 * @since 2023-04-03
 */
@RestController
@RequestMapping("/taskInfoLocal")
public class TaskInfoLocalController {

    @Autowired(required = false)
    private TaskInfoLocalService taskInfoLocalService;

    /**
     * 新增任务
     */
    @RequestMapping(value = "/add", method = {RequestMethod.POST}, produces = "application/json")
    public CommonVO<Object> add(@RequestBody TaskInfoLocal taskInfoLocal)
    {
        taskInfoLocalService.insert(taskInfoLocal);
        return new CommonVO<>();
    }

    /**
     * 新增任务
     */
    @RequestMapping(value = "/update", method = {RequestMethod.POST}, produces = "application/json")
    public CommonVO<Object> update(@RequestBody TaskInfoLocal taskInfoLocal)
    {
        taskInfoLocalService.update(taskInfoLocal);
        return new CommonVO<>();
    }


    /**
     * 删除任务
     */
    @RequestMapping(value = "/delete", method = {RequestMethod.POST}, produces = "application/json")
    public CommonVO<Object> remove(@RequestBody List<Long> ids)
    {
        taskInfoLocalService.deleteByIds(ids);
        return new CommonVO<>();
    }

    /**
     * 获取快捷键详细信息
     */
    @GetMapping(value = "/info/{id}")
    public CommonVO<Object> getInfo(@PathVariable("id") Long id)
    {
        return new CommonVO<>(taskInfoLocalService.selectById(id));
    }


    @RequestMapping(value = "/list", method = {RequestMethod.POST}, produces = "application/json")
    public CommonVO<Object> list(@RequestBody TaskInfoLocal taskInfoLocal)
    {

        PageInfo<TaskInfoLocal> pageInfo = taskInfoLocalService.list(taskInfoLocal);
        return new CommonVO<>(pageInfo);
    }
}

